//
//  HotTableView.m
//  RentTable
//
//  Created by mac on 2024/11/29.
//

#import "HotTableCell.h"

@interface HotTableCell()

@property (nonatomic, strong) UILabel *hotPriceLabel;
@property (nonatomic, strong) UILabel *hotPriceDayLabel;
@property (nonatomic, strong) UILabel *hotLabel;
@property (nonatomic, strong) UIImageView *hotImageview;

@end

@implementation HotTableCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self == [super initWithFrame:frame]) {
        [self setUI];
    }
    return self;
}

- (void)setPrice:(NSString *)price describe:(NSString *)describe image:(NSString *)image {
    self.hotPriceLabel.text = price;
    self.hotLabel.text = describe;
    self.hotImageview.image = [UIImage imageNamed:image];
}

- (void)setUI {
    
    self.backgroundColor = myRGBHex(0xF5F5F5);
    self.layer.cornerRadius = 10;
    self.layer.masksToBounds = true;
    
    self.hotPriceLabel = [[UILabel alloc] init];
    self.hotPriceLabel.font = [UIFont pingFangSCRegularWithSize:16];
    self.hotPriceLabel.textColor = myRGBHex(0x333333);
    self.hotPriceLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.hotPriceLabel];
    [self.hotPriceLabel sizeToFit];
    [self.hotPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(12);
        make.leading.mas_equalTo(10);
        make.height.mas_equalTo(18);
    }];
    
    self.hotPriceDayLabel = [[UILabel alloc] init];
    self.hotPriceDayLabel.font = [UIFont pingFangSCSemiboldWithSize:10];
    self.hotPriceDayLabel.textColor = myRGBHex(0x999999);
    self.hotPriceDayLabel.textAlignment = NSTextAlignmentLeft;
    self.hotPriceDayLabel.text = @"/天";
    [self addSubview:self.hotPriceDayLabel];
    [self.hotPriceDayLabel sizeToFit];
    [self.hotPriceDayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.hotPriceLabel.mas_centerY);
        make.leading.equalTo(self.hotPriceLabel.mas_trailing).offset(7);
        make.height.mas_equalTo(18);
    }];
    
    
    self.hotLabel = [[UILabel alloc] init];
    self.hotLabel.font = [UIFont pingFangSCRegularWithSize:11];
    self.hotLabel.textColor = myRGBHex(0x333333);
    self.hotLabel.textAlignment = NSTextAlignmentLeft;
    self.hotLabel.numberOfLines = 0;
    [self addSubview:self.hotLabel];
    [self.hotLabel sizeToFit];
    [self.hotLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hotPriceLabel.mas_bottom).offset(8);
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-10);
        make.height.lessThanOrEqualTo(@50);
    }];
    
    self.hotImageview = [UIImageView new];
    [self addSubview:self.hotImageview];
    [self.hotImageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-10);
        make.bottom.mas_equalTo(-2);
        make.top.equalTo(self.hotLabel.mas_bottom).offset(5);
    }];
}

@end
